home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Zomo's Site / iwan_tut2_eng.rar.txt / iwan_tut2_E.txt < prev   
Text File  |  1999-05-03  |  9KB  |  219 lines

  1. ____________________________________________________________________________________                                                          
  2.                     _________\          |            __________  
  3.                    /          \      __-+-  __      |         /\ 
  4.                   /___________/     /'( |_  )`\     |________/  \
  5.                  |   \       /     / . \/^\/ . \            /   /
  6.                   \   \           /  _)_`-'_(_  \          /   / 
  7.                    \   \         /.-~   ).(   ~-.\        /   /  
  8.                     \   \       /'     /\_/\     `\      /   /   
  9.                      \  /     __  ___  " __"  __  _ _  \/   /    
  10.                       \/     / _)(  ,)  (  ) / _)( ) )  \__/_    
  11.                             ( (_  )  \  /()\( (_  )  \           
  12.                              \__)(_)\_)(_)(_)\__)(_)\_)          
  13.                                 ___             __               
  14.                                (  ,\o l a n d  (  )              
  15.                                 ) _/ cRACKING   )(__             
  16.                                (_)      gROUP  (____)            
  17.                                     ____     /\                  
  18.                                    /  \     /  \                 
  19.                                   /\   \   /   /                 
  20.                                     \   \ /   /                  
  21.                                      \___\___/                   
  22. _______________________________________________________________________________________
  23.  
  24.                                 CrackPl presents 
  25.                 iwan's tutorial#2
  26. _______________________________________________________________________________________
  27.  
  28. Target: mIRC 5.41
  29. Weapon: Softice
  30.  
  31. If this tutorial helped you to learn sth new please let me know ---> iwy@friko.onet.pl 
  32.  
  33. So let's start the show. Run Mirc32.exe and choose Register... from Help menu. We enter random data, for example:
  34.  
  35. Full Name: Iwan'98
  36. Registration Code: 34343434
  37.  
  38. As we can notice, standard breakpoints on GetWindowTextA or GetDlgItemTextA don't work. What can we do then? As usually there are quite a few solutions.
  39. In my last tutorial (Teleport Pro) I suggested you to try breakpoint on HMEMCPY (who did try? ;-)). Let's do it then. We do Ctrl+D and:
  40.  
  41. BPX HMEMCPY
  42.  
  43. We go back to win, press Register and... we are back in SoftIce. We get out once more (we are intereseted in the Registration Code, right?) and F11 to get to the Mirc code. But we're not in the Mirc code yet! Of course we have to go futher. So put your finger on F10 and press it untill you get there (it may be a few dozen of presses). Stop as soon as you are in the Mirc code. How do we know we are there? We should know it if you have read my previous tut. 
  44.  
  45. ---------------------------
  46. Newbies Note!
  47. Notice that when using bpx on HMEMPY usually just before it you go through KERNEL32!_FREQASM.
  48. ---------------------------
  49.  
  50. OK. We can see sth like that:
  51.  
  52. :0043D1B5    PUSH 004D1E70
  53. :0043D1BA    PUSH 004D1BB4
  54. :0043D1BF    CALL 0048E608
  55.  
  56. Let's chech what goes to the stack.
  57.  
  58. D 4D1E70
  59.  
  60. Our serial.
  61.  
  62. D 4D1BB4
  63.  
  64. Our name.
  65. It's useful to remember these addresses.
  66. So we probably are in the right place to start our analysis :-)
  67. We get into call at 0043D1BF and after a few F10 we see:
  68.  
  69. :0048E606    MOV ESI,[EBP+0C]
  70. :0048E611    MOV EBX,[EBP+08]
  71. :0048E614    PUSH EBX
  72. :0048E615    CALL 004B39C8
  73.  
  74. Hmm, maybe we wonder what goes into ESI after 0048E606?
  75. Let's chech it.
  76.  
  77. D EBP+0C
  78.  
  79. There is nothing important in the data window but... remember when we lately read from right to left? The first line in the data windows starts like this:
  80.  
  81. :0087F9F8    70 1E 4D 00 ....etc.
  82.  
  83. Remember where was our serial? At 004D1E70. Let's read these numbers from the data window 'from the other side'. Kewl, we've got our serial's address! 
  84. You can analyse MOV EBX,[EBP+08] the same way.
  85.  
  86. ---------------------------
  87. Newbies Note!
  88. To make life easier you could just type
  89. D *(EBP+C)
  90. to get same. Cool, ha?
  91. ---------------------------
  92.  
  93. OK, we F8 into CALL 0044B39C8. Notice that before this call the value from EBX was send to the stack (our name).
  94.  
  95. ---------------------------
  96. Newbies Note!
  97. Usually when there is FFFFFFFF in the ECX registry the procedure counts a number of signs in our serial or name. 
  98. ---------------------------
  99.  
  100. We get (F10) to RET and go back from the procedure. As we can see there is 7 in EAX. Correct! Iwan'98 has exactly 7 signs.
  101. Further we see: 
  102.  
  103. :0048E61B    CMP EAX,05
  104. :0048E61B    JAE 0048E624
  105.  
  106. The number of signs is compared to 5 and then jump in the line below 'lets go' only when it's equal or greater than it. We met this demand. Ok, let's get some more:
  107.  
  108. :0048E626    CALL 0048E528
  109.  
  110. Besides PUSHing our name and serial we see:
  111.  
  112. :0048E534    PUSH 2D
  113.  
  114. What is it 2D? If you are not familiar with hex numbers do:
  115.  
  116. ? 2D
  117.  
  118. It's a dash ('-'). There is a CALL two lines later. We find sth like this:
  119.  
  120. :004B3989    MOV EDI,EDX
  121. :004B398B    MOV AL,(EBP+0C]
  122. :004B398E    REPNZ SCASB
  123. :004B3990    JNZ 00483998
  124.  
  125. Our serial is in EDI and '-' goes to AL (so there is 2D in EAX). I the dash is not found in the serial, the jump sends us ultimately to 'Bad_Boy_Go_Away'. 
  126. Well, we know now that there MUST be a dash in our serial! At a moment we have to stop the code analysis. We go back to the register window (disable bpx before it!: BD 0 ;-)).
  127. We correct our fake serial from 34343434 to 3434-5656. Back in SoftIce we enable (BE 0) our breakpoint. What next? We do everything we did before till we get to :004B3990 (if you where smart enough you breakpointed this line earlier :-)).
  128. This time the jump won't be executed so we can analyse Mirc code further. 
  129.  
  130. :004B3992    LEA EAX,[EDI-01]
  131.  
  132. One part of our serial goes to EAX. We go through RET and we find:
  133.  
  134. :0048E550    CALL 004B8D5C
  135.  
  136. and later
  137.  
  138. :0048E577    CALL 004B39C8
  139.  
  140. I leave a detailed analysis of these two CALLs for persistent ones ;-) I suggest only two things:
  141. 1. The first CALL checks whether the signs in our serial are in the range <0;9>, 2. The second one counts a number of signs in our name once more :-) (???).
  142.  
  143. Starting at 
  144. 0048E594    MOVZX ESI,BYTE PTR [ECX] 
  145. a real serial is calculated (actually a first part of it). You must patiently go through this piece of code. 
  146. We see:
  147.  
  148. :0048E5B0    CMP EBX,[EBP-04]
  149.  
  150. What a nice compare :-) Let's check what we can find at [EBP-04]
  151.  
  152. D EBP-4
  153.  
  154. You already know the 'right-to-left-reading' In the data window we see:
  155.  
  156. :0087F9CC    6A 0D 00 ....
  157.  
  158. so we check:
  159.  
  160. ? 0D6A
  161.  
  162. Actually if you have learned sth from my tutorial you'd rather do:
  163.  
  164. D *(EBP-4)
  165.  
  166. Did you? Good boy ;-)
  167.  
  168. Kewl, it's our serial (till the dash). How do you think, what is it comared to?
  169.  
  170. ? EBX
  171.  
  172. Yes, it's the first part of the REAL serial :)). Write it down! 
  173.  
  174. There is a jump one line below:
  175.  
  176. : 0048E5B3    JZ 0048E5B9
  177.  
  178. At a moment Mirc doesn't feel like jumping at the address. Why? Well, the comapison above didn't give ZERO (because both sides weren't equal). 
  179.  
  180. ---------------------------
  181. Newbies Note!
  182. The compare instruction (CMP) subtrackts one value from the other. If the values are equal the result is ZERO and a Z(ero) flag is set.
  183.  ---------------------------
  184.  
  185. OK, let's get back to the code. To execute this jump we could go back to the registration window and change the serial's part we already know. Do it if you wish! I prefer a faster solution. At:
  186.  
  187. :0048E5AE    JZ 0048E5B9
  188.  
  189. we change the Z(ero) flag:
  190.  
  191. R FL Z
  192.  
  193. Now Mirc is willing to co-operate ;-) Kewl.
  194.  
  195. Right after that jump we see a piece of code that looks pretty familiar. Starting at :0048E5CD the second part of our serial is being calculated. You have to be patient once more (patience in an important feature of a good reverser!) till:
  196.  
  197. :0048E5F0    CMP EBX,[EBP-08]
  198.  
  199. I guess you know what it means. Just check: 
  200.  
  201. D *(EBP-8)
  202.  
  203. It's time to end up our game.
  204.  
  205. ? EBX
  206.  
  207. Yeap, that's the 2nd part of the REAL serial! 
  208.  
  209. Now the Mirc protection mechanism is as clear as Moskovskaia vodka ;-) If either sth was not understandable or this tutorial helped you to improve your knowledge about revers engineering please let me know.  
  210.  
  211. --------------------------------------------------------------------------------------
  212. If you are looking for serials, you are in a wrong place.
  213. The goal of the actions described above is to analyze program code and protetion system.
  214. If you are going to use this program longer, buy it (does not concern M$).
  215. It will make possible for programmer to improve their programs and protection systems.
  216. --------------------------------------------------------------------------------------
  217. 17/12/98 by iwan (iwy@friko.onet.pl) - polish version
  218. 03/05/99 translated and slightly modified by iwan
  219.